<template>
	<view class="f-center">
		<button class="zc-button-default" :disabled="DissBtn_XXX" :loading="LoadBtn_XXX" @click="doBtn_XXX">{{Text_XXX}}</button>
	</view>
</template>

<script>
	export default {
		name: 'zcButton',
		props: {
			IsLogin: {
				type: String,
				default: 'true'
			},
			Name: {
				type: String,
				required: true
			},
			Action: {
				type: String,
				required: true
			},
			Text: {
				type: String,
				default: '未定义'
			},
			WaitModel: {
				type: String,
				default: '2'
			},
			Btn_disabled:{
				type:Boolean,
				default:false
			}
		},
		watch:{
			Text(newV,oldV){
				this.Text_XXX = newV;
			},
			Btn_disabled(newV,oldV){
				this.DissBtn_XXX = newV;
			}
		},
		data() {
			return {
				Text_XXX: '未定义',
				IsLogin_XXX: 'true',
				WaitModel_XXX: '2',
				Name_XXX: '',
				Action_XXX: '',
				DissBtn_XXX: false,
				LoadBtn_XXX: false
			};
		},
		created() {
			let me = this;
			me.Text_XXX = me.$props.Text;
			me.IsLogin_XXX = me.$props.IsLogin;
			me.WaitModel_XXX = me.$props.WaitModel;
			me.Name_XXX = me.$props.Name;
			me.Action_XXX = me.$props.Action;
			me.DissBtn_XXX = me.$props.Btn_disabled;
		},
		methods: {
			cbBtn_XXX: function(jsonData, scope) {
				let me = this;
				if (jsonData.success) {
					uni.showToast({
						title: '执行成功'
					});
					me.$emit('doBackData', jsonData);
				} 
				else {
					me.$ZcPublic.Err(jsonData.msg);
				}
			},
			reBtn_XXX: function() {
				let me = this;
				// 恢复按钮状态
				if(me.$ZcPublic.WaitModel != '0') {
					if(me.WaitModel_XXX == '2') {
						me.LoadBtn_XXX = false;
						me.DissBtn_XXX = false;
					}
				}
			},
			doBtn_XXX: function() {
				let me = this;
				let para = {
					success: true,
					data:null,
					msg:''
				}
				me.$emit('doMakeData', para);
				if (para.success === false) {
					
					if (para.msg) {
						me.$ZcPublic.Msg(para.msg);
					}
					return;
				}
				
				if(me.$ZcPublic.WaitModel != '0') {
					if (me.WaitModel_XXX == '2') {
						me.LoadBtn_XXX = true;
						me.DissBtn_XXX = true;
					}	
				}
				me.$ZcPublic.Server.ButtonPost({
					IsNeedLogin: me.IsLogin_XXX,
					Paras: {
						Name: me.Name_XXX,
						Action: me.Action_XXX,
						Data: para.data
					},
					WaitModel:me.WaitModel_XXX,
					Fn_Success: me.cbBtn_XXX,
					Fn_Complete: me.reBtn_XXX,
					Scope: me
				});
			}
		}
	}
</script>

<style>
	.zc-button-default {
		background: transparent;
		border: none;
	}

	
button[disabled]{
background:transparent !important;
}
</style>
